package com.fairytask.extention;

import com.fairytask.extention.define.CustomToServerDefine;
import com.fairytask.extention.scene.SceneEnterHandler;
import com.fairytask.extention.user.UserLoginHandler;
import com.qq.open.OpenApiV3;
import com.smartfoxserver.v2.components.login.LoginAssistantComponent;
import com.smartfoxserver.v2.core.SFSEventType;
import com.smartfoxserver.v2.extensions.SFSExtension;

public class LoginExtention extends SFSExtension {
	private LoginAssistantComponent lac;
	//测试用
	private String appid	=	"100699274";
	private String appkey="d3beed4ef416398cbc349467c35a21a6";
	private String serverName="119.147.19.43";
	
	//腾讯调用地址
	public static OpenApiV3 OpenApi;
	public static String pf	=	"qzone";
	
	/**{@inheritDoc}**/
	public void	init()
	{
		OpenApi	=	new OpenApiV3(appid, appkey);
		OpenApi.setServerName(serverName);
		//直接自定义用户登陆吧
		addEventHandler(SFSEventType.USER_LOGIN, UserLoginHandler.class);
		//房间管理
		addRequestHandler(CustomToServerDefine.CREATE_ROOM,UserInfoHandler.class);
		//先要取得用户
		addRequestHandler(CustomToServerDefine.USER_GET, UserInfoHandler.class);
		addRequestHandler(CustomToServerDefine.API_QQ_ALL, OpenApiHandler.class);
		addRequestHandler(CustomToServerDefine.USER_REGISTER, UserRegisterHandler.class);
		addRequestHandler(CustomToServerDefine.SCENE_ENTER, SceneEnterHandler.class);
		//
		//addEventHandler(SFSEventType.SERVER_READY, theClass)
	}
	/**{@inheritDoc}**/
	@Override
	public void destroy()
	{
		lac.destroy();
		super.destroy();
	}
}
